package com.neusoft.databus.agent.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "dababus.plugins.porttraffic", ignoreUnknownFields = false)
public class PorttrafficPluginProperties {

    private final Pool pool = new Pool();

    @Getter
    @Setter
    public static class Pool {
        // 允许创建资源的最大数量
        private int maxTotal = 24;
        private int maxTotalPerKey = 8;
        // 当资源耗尽时，是否阻塞等待获取资源
        private boolean blockWhenExhausted = true;
        // 获取资源时的等待时间，单位毫秒。当 blockWhenExhausted 配置为 true 时，此值有效
        private long maxWaitMillis = 1000 * 10;
        // 当创建资源时会调用 factory.validateObject() 方法
        private boolean testOnCreate = true;
        // 每次从池中获取资源时都会调用 factory.validateObject() 方法
        private boolean testOnBorrow = true;
        // 回收资源线程的执行周期，单位毫秒。默认值 -1 ，-1 表示不启用线程回收资源
        private long timeBetweenEvictionRunsMillis = -1;
        // 资源最小空闲时间， 默认值 1800000，单位 毫秒
        private long minEvictableIdleTimeMillis = 1000 * 60 * 30;
    }
}
